package com.njtoyo.taxi.admin.rest.controller.business;

import com.njtoyo.taxi.admin.rest.wrapper.business.ride.DesignatedRideQueryWrapper;
import com.njtoyo.taxi.admin.rest.wrapper.business.ride.UpdateOrderAmountWrapper;
import com.njtoyo.taxi.admin.service.business.DesignatedService;
import com.njtoyo.taxi.entity.backend.AdminUser;
import com.taxi.entity.common.RestResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 代驾
 */
@RestController
@RequestMapping("business/designated")
public class DesignatedController {

    @Autowired
    private DesignatedService designatedService;


    @GetMapping("/list")
    RestResult getRideList(@ModelAttribute("admin") AdminUser adminUser, DesignatedRideQueryWrapper wrapper) {
        return designatedService.getList(adminUser, wrapper);
    }




    @PatchMapping("/{id}/update-amount")
    @ApiOperation(value = "修改未付款订单金额")
    RestResult<Boolean> updateOrderAmount(@PathVariable("id") Long id, @Valid @RequestBody UpdateOrderAmountWrapper wrapper) {
        return designatedService.updateOrderAmount(id, wrapper);
    }

    @GetMapping("/{id}/track")
    @ApiOperation(value = "行程轨迹", notes = "权限：ride_track_log")
    RestResult getTrack(@PathVariable("id") Long id) {
        return designatedService.getTrack(id);
    }


    @GetMapping("/{id}")
    @ApiOperation(value = "行程详情")
    RestResult getRideDetail(@PathVariable("id") Long callId) {
        return designatedService.getRideDetail(callId);
    }


    @PostMapping("/{id}/order/refund")
    @ApiOperation(value = "代驾退款")
    RestResult<Boolean> orderRefund(@PathVariable("id") Long callId) {
        return designatedService.orderRefund(callId);
    }
}
